<?php
namespace Home\Controller;

use Think\Controller;
/**
 * 示例
 */
class DemosController extends Controller
{

    /**
     * 列表
     */
    public function index()
    {
        //头部banner
        $this->banner = getBanner();

        //解决方案
        $where = array();
        $where['status'] = 1;
        $where['pid'] = 0;
        $solution_p = M('solution')->where($where)->order(array('id' => 'desc'))->select();
        if(count($solution_p) > 0){
            foreach ($solution_p as &$v){
                $v['exist_child'] = 1;
                $v['child'] = M('solution')->where(array('pid' => $v['id'], 'status'=>1))->select();
            }
        }
        $this->solution = $solution_p;

        $this->display(); // 输出模板
    }

    /**
     * 详情
     * @return [type] [description]
     */
    public function detail($id="")
    {
        //头部banner
        $this->banner = getBanner();

        //查询详情
        $this->info = M('demos')->find($id);

        $this->display(); // 输出模板
    }
}
